home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / RTPC10 / MANUAL.TXT < prev    next >
Text File  |  1993-11-22  |  40KB  |  1,169 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                   Rafe's
  7.                     TP
  8.                 Collection
  9.  
  10.                    Release 1.0
  11.  
  12.                  By Rafe Aldridge
  13.  
  14.                    Street Farm,
  15.                   Dereham Road,
  16.                    Garvestone,
  17.                 Norfolk.
  18.                 NR9 4QT
  19.                 ENGLAND
  20.  
  21.            E-Mail
  22.            until July 1994: rca@ib.rl.ac.uk
  23.   then from September 1994 to July 1995: rcaldrid@genvax.glam.ac.uk
  24.  
  25. (if this doesn't work check the username with postmaster@genvax.glam.ac.uk)
  26.  
  27. Welcome, Disclaimer etc.
  28.  
  29. Thanks for taking the time to look at my collection of stuff for
  30. Turbo Pascal Versions 6 and 7. Hopefully, you will find it
  31. useful and will learn something from it. Please feel free to
  32. write to me with any ideas or comments at the address shown at
  33. the front of this document.
  34.  
  35. This collection is distributed as shareware as it's taken me a
  36. long time to compile this collection and a large proportion of
  37. my student loan has gone to Borland in order for it to happen.
  38. So if  you find any part of Rafe's TP Collection useful then 
  39. please become a registered user by sending 10 Pounds Sterling 
  40. (plus shipping which is free in the UK, £1 for Europe and £2 for
  41. the rest of the world) to the address given at the front of this
  42. document. In return you will receive the LATEST  FULL source
  43. code to ALL the units as well anything new. When you do register
  44. please try and use the registration form on the next page. This
  45. is also duplicated in REGISTER.FRM so you can either edit it
  46. in your favourite word processor or print out a copy with COPY
  47. REGISTER.FRM PRN. Apologies for the copyright message which will
  48. appear if you use the units but I want to encourage you to
  49. register (registered units don't have it).
  50.  
  51. Please feel free to make copies of this collection, pass it onto
  52. friends, upload it to BBSs, FTP it across the globe, whatever,
  53. so long as it stays complete. NOTE to vendors:  Please drop me a
  54. note when adding the collection to your library. I would like to
  55. hear from you.
  56.  
  57. Finally, just to cover myself, I must say: THIS SOFTWARE AND
  58. MANUAL ARE  DISTRIBUTED "AS IS" AND WITHOUT ANY WARRANTIES AS TO
  59. PERFORMANCE OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER
  60. EXPRESSED OR IMPLIED. BECAUSE OF THE VARIOUS HARDWARE AND
  61. SOFTWARE ENVIRONMENTS  THAT THIS SOFTWARE CAN BE PUT, NO
  62. WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. GOOD
  63. DATA PROCESSING PROCEDURE DICTATES THAT ANY PROGRAM BE
  64. THOROUGHLY TESTED WITH NON-CRITICAL DATA BEFORE RELYING ON IT.
  65. THE USER MUST ASSUME THE ENTIRE RISK OF USING THE UNITS OR
  66. SAMPLE CODE. ANY LIABILITY OF THE SELLER WILL BE LIMITED
  67. EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF THE PURCHASE
  68. PRICE.
  69.  
  70. Thanks again.
  71.  
  72. Rafe Aldridge.
  73.  
  74. Everything in Rafe's TP Collection is Copyright 1993 by Rafe Aldridge.
  75.  
  76. Registration Form
  77.  
  78. Send to:
  79. Rafe Aldridge,
  80. Street Farm,
  81. Dereham Road,
  82. Garvestone,
  83. Norfolk.
  84. NR9 4QT
  85. England
  86.  
  87. Please make cheques payable to Rafe Aldridge and write your card
  88. number on the reverse.
  89.  
  90. I would like to register Rafe's TP Collection Version 1.0. My
  91. details are as below and I enclose a cheque for £10 (pounds
  92. sterling) plus shipping (free if in UK, £1 for Europe and £2 for
  93. the rest of the world).
  94.  
  95. Name    
  96. Company         
  97. Address         
  98. Town    
  99. City    
  100. Postcode        
  101. Country         
  102. Telephone  (optional)   
  103. E-Mail Address  
  104. Disk Size Required       o 3.5" LD     o 3.5" HD     o 5.25" HD 
  105. I got  Rafe's TP Collection from:       
  106. Which is a:      o BBS     o FTP Site     o Mail Server     o Shareware Vendor
  107.  
  108. Archive Contents
  109.  
  110. The following files will be found in the archive:
  111.  
  112. Filename        Description 
  113. BASEN.TP?       A unit for converting between various number bases 
  114. BASEN_D.PAS     Example program for the above  
  115. BLANK.PAS       Example program that acts as a screen blanker.
  116. CLICK.PAS       Example program demonstrating the writing of simple TSRs 
  117. DESIGN.EXE      Program to aid the design of VGA characters 
  118. DISKSUM.PAS     Example program showing a recursive disk search 
  119. DJDUMP.PAS      Example procedure for dumping graphics to the HP DeskJet 
  120. GCLOCKS.TP?     A unit for displaying analogue / digital clocks in
  121.         graphics modes (requires GRAPH) 
  122. GRAFIX.TP?      A unit for to supplement the graph unit (including
  123.         faster plot routine) 
  124. JOKE.PAS        Example program demonstrating avoiding re-entrancy in TSRs 
  125. MATHS.TP?       A unit of maths functions not included as standard
  126.         with TP/BP 
  127. MATRICES.TP?    A unit for manipulating small (5x5) matrices 
  128. MDA.TP?         A unit for controlling a MDA (monochrome display adaptor) 
  129. MOUSE.TP?       A unit for using a mouse in your programs 
  130. MOUSE_D.PAS     Example program for the above  
  131. NO_MD_RD.ASM    Assembler program demonstrating a simple TSR 
  132. SCREEN.TP?      A unit with some usefull text based routines 
  133. VGA.TP?         A unit to aid programming in 320x200x256 VGA graphics mode 
  134. VGA_D.PAS       Example program for the above  
  135. MANUAL.TXT      The manual in plain text format 
  136. MANUAL.PS       The manual typeset in PostScript format (22 Pages).
  137. READ.ME         Last minute additions and the ususal stuff 
  138. RAFETP.DIZ      Description for vendors 
  139. INSTALL6.BAT    A batch file to set up Rafe-TP for TP6 
  140. INSTALL7.BAT    A batch file to set up Rafe-TP for TP/BP7 
  141. REGISTER.FRM    Registration Form 
  142.  
  143. The Programs
  144.  
  145. Blank.pas
  146. This demonstrates the writing of simple TSRs in Turbo Pascal.
  147. It hooks both the keyboard and timer intterupts and acts as
  148. a screen saver.
  149.  
  150. Click.pas
  151. This demonstrates the writing of very simple TSRs in Turbo
  152. Pascal. Basically it hooks the keyboard interrupt and makes a
  153. click every time a key is pressed. This program also
  154. demonstrates how to keep data in the code segment.
  155.  
  156. Design.exe
  157. This is a simple program to help design characters for use with
  158. the def_char procedure from the screen unit.
  159.  
  160. Disksum.pas
  161. This is an example of recursion in Turbo Pascal by means of a
  162. recursive disk search
  163.  
  164. DJDump.pas
  165. Although not a complete program this example procedure shows how
  166. to dump graphics to the HP DeskJet. It also includes a small
  167. piece of assembler to read pixels of a graphics screen without
  168. the need of the Graph unit and BGI. NOTE: it was written for use
  169. with the 640x480x16 VGA graphics mode.
  170.  
  171. Joke.pas
  172. Another example of simple TSRs that also demonstrates how to
  173. avoid re-entrancy.
  174.  
  175. No_md_rd.asm
  176. Assembler program demonstrating a simple TSR. Seeing as
  177. TASM comes with Turbo Pascal Professional and Borland Pascal I
  178. thought I'd include this for the adventurous.
  179.  
  180. The Units
  181.  
  182. All the units were compiled with the switches {$D-,L-,R-} except
  183. for the Maths unit which was compiled with {$D-,E+,L-,N+,R-}.
  184. Hopefully these will be okay for most purposes otherwise
  185. register and you can compile them with whatever switches you
  186. desire.
  187.  
  188. Below is an alphabetical list of all the procedures found in the
  189. various units, supplied as part of the Rafe-TP collection, in
  190. the style of the Turbo Pascal manuals.
  191.  
  192. The following is a sample table.
  193.  
  194. Sample procedure - Unit it occupies
  195. Function        What it does
  196. Declaration     How it is declared in the unit
  197. Result Type     If a function this gives the type of result
  198. Remarks         General information
  199. Restrictions    Restrictions or points to watch out for
  200. Example         An example if applicable
  201.  
  202. Add_Matrix procedure - Matrices
  203. Function        Adds two matrices.
  204. Declaration     Add_Matrix ( M1,M2 : Matrix; var M : Matrix );
  205. Remarks         Returns in matrix M the sum of M1 and M2.
  206.  
  207. AFace procedure - GClocks
  208. Function        Displays an analogue clockface.
  209. Declaration     AFace (X,Y,L : Integer);
  210. Remarks         Displays dots for an analogue clockface. The center of
  211.         the clockface is X,Y and the radius of the clockface is L.
  212. Restrictions    Must be in graphics mode and be using the Graph unit
  213. Example         See AHands Procedure.
  214.  
  215. AHands procedure - GClocks
  216. Function        Displays a analogue clockface.
  217. Declaration     AHands (X,Y,L : Integer; H,M : Word);
  218. Remarks         Displays the hands of an analogue clock. The time is
  219.         given by H:M and the centre of the clock
  220.         face is X,Y and the length of the minute hand is given by L.
  221. Restrictions    Must be in graphics mode and be using the Graph unit
  222. Example 
  223.     Uses GClock;
  224.         Var H,M,S,SS,OH,OM : word;
  225.     Begin
  226.         { set up graphics mode here }
  227.         Repeat
  228.             AFace(50,50,28);
  229.             GetTime(H,M,S,SS);
  230.             If M<>OM then
  231.             Begin
  232.                 SetColor(Black);
  233.                 AHands(50,50,25,OH,OM);
  234.                 SetColor(White);
  235.                 AHands(50,50,25,H,M);
  236.                 OM:=M;
  237.                 OH:=H;
  238.             End;
  239.         Until False;
  240.     End.
  241.  
  242. Bin function - Basen
  243. Function        Converts a decimal value into a binary string.
  244. Declaration     Bin ( Length : Byte; Dec_Val : Word; LZero : boolean );
  245. Result Type     String
  246. Remarks         Converts Dec_Val into a string of Length representing
  247.         the binary equivalent. If LZero is true then leading zeros 
  248.         are suppressed. Length is between 1 and 16.
  249. Example         
  250.     Uses Basen;
  251.     Begin
  252.         Writeln (Bin(4,5,True));{ 101 }
  253.         Writeln (Bin(4,5,False)); { 0101 }
  254.     End.
  255.  
  256. BinByte function - Basen
  257. Function        Converts a binary number  into a byte.
  258. Declaration     BinByte ( S : String );
  259. Result Type     Byte
  260. Remarks         Converts a binary number stored in string S into the
  261.         decimal equivelent. Note that the length of S must be 8 
  262.         characters - otherwise the value returned will be 0.
  263. Example 
  264.     Uses Basen;
  265.     Begin
  266.         Writeln (BinByte ('10101010'));
  267.     End.
  268.  
  269. Blink_Disable - Mda
  270. Function        Disables blinking on the MDA Screen
  271. Declaration     Blink_Disable;
  272.  
  273. Blink_Enable - Mda
  274. Function        Enables blinking on the MDA Screen
  275. Declaration     Blink_Enable;
  276.  
  277. Box procedure - Screen
  278. Function        Draws a shadowed box on the text screen.
  279. Declaration     Box (X1,Y1,X2,Y2 : Byte; C : Char;  T : String);
  280. Remarks         Draws a box in double lines using character C for the
  281.         shadow. The top of the box can contain a title, T. X1,Y1 
  282.         is the top left hand corner of the box while X2,Y2 is the 
  283.         bottom right corner.
  284.  
  285. Clear_Box procedure - Screen
  286. Function        Clears part of thescreen.
  287. Declaration     Clear_Box ( C : Byte; var H : Hidden_Area );
  288. Remarks         Clears a 20x10 box in the centre of the screen coloured
  289.         C. The previous contents are stored in H ready to be replaced 
  290.         by Restore_Box.
  291. Example         See Restore_Box.
  292.  
  293. CloseVGA procedure - VGA
  294. Function        Close the VGA graphics mode.
  295. Declaration     CloseVGA;
  296. Remarks         This closes the VGA graphics mode and returns to
  297.         80x25x16 text mode.
  298.  
  299. Cosh function - Maths
  300. Function        Returns the Hyp Cosine of the argument.
  301. Declaration     Cosh (X : Real);
  302. Result Type     Real
  303. Remarks         X is a real type expression. The result is Hyp Cosine of X.
  304. Example 
  305.         Uses Maths;
  306.         Begin
  307.             Writeln (Cosh(2));  { 3.7621 }
  308.             Writeln (Cosh(-4)); { 27.308 }
  309.         End.
  310.  
  311. Create_Matrix procedure - Matrices
  312. Function        Creates a matrix
  313. Declaration     Create_Matrix ( R,C : Byte; var M : Matrix );
  314. Remarks         Creates an empty matrix, M, with R rows and C columns.
  315.  
  316. CursorOn procedure - Screen
  317. Function        Turns the text cursor on and sets the start and stop
  318.         scan lines.
  319. Declaration     CursorOn ( H,L : Byte );
  320. Remarks         Turns the text cursor on. Cursor starts at line L and
  321.         finishes at line H. L and H are between 0 and 7 for 25 line 
  322.         mode and between 0 and 15 for 43 or 50 line mode. If L and H 
  323.         are both set greater than 15 then the default cursor is set.
  324. Example 
  325.         Uses Text;
  326.         Begin
  327.             CursorOff;
  328.             Writeln ('Return to Show Cursor');
  329.             Readln;
  330.             CursorOn (0,7);
  331.             Writeln ('Return to Reset Cursor');
  332.             Readln;
  333.             CursorOn (16,16);
  334.         End.
  335.  
  336. CursorOff procedure - Screen
  337. Function        Turns the text Cursor off.
  338. Declaration     CursorOff;
  339. Remarks         Use CursorOn to retrieve cursor.
  340. Example         See CursorOn.
  341.  
  342. D2R function - Maths
  343. Function        Converts degrees to degrees radians.
  344. Declaration     D2R ( X : Real );
  345. Result Type     Real
  346. Remarks         X is a real type expression representing an angle in
  347.         degrees. The result represents the angle in degrees radians.
  348. Example 
  349.         Uses Maths;
  350.         Begin
  351.             Writeln (D2R(90));{ 1.57 }
  352.         End.
  353.  
  354. Def_Char procedure - Screen
  355. Function        Redefines a VGA text character.
  356. Declaration     Def_Char (CT_Ofs, CT_Seg, N, C : Word);
  357. Remarks         A VGA character is 8x16 pixels and can therefore be
  358.         described in a 16 byte array where each byte in binary 
  359.         represents which pixels will be lit on that line. Def_Char 
  360.         can be used to redefine a VGA character from such an array. 
  361.         CT_Seg:CT_Ofs points to the array (which can contain more 
  362.         than one set of 16 Bytes). N represents the number of 
  363.         characters to redefine and C is the starting character. 
  364.         The program DESIGN.EXE, supplied with this collection
  365.         can be used to define these characters.
  366. Example 
  367.         Uses Screen;
  368.             Const New_Char : array [1..16] of byte = 
  369.             (1,2,4,8,16,32,64,128,255,128,64,32,16,8,4,2,1);
  370.         Begin
  371.             Def_Char (Ofs (New_Char), Seg (New_Char, 1, 128);
  372.             Write ('Character 128 has been redefined ');
  373.             Write (#128);
  374.             Writeln;
  375.             Writeln ('Use the DOS command MODE CO80 to reset 
  376.         the character set');
  377.         End.
  378.  
  379. Display_Matrix procedure - Matrices
  380. Function        Used to display a matrix.
  381. Declaration     Display_Matrix ( X, Y : Byte; M : Matrix );
  382. Remarks         Outputs the matrix M to the screen at the position given 
  383.         by X,Y.
  384.  
  385. DClock procedure - GClocks
  386. Function        Displays a digital clock on the screen.
  387. Declaration     DClock (X,Y : Integer; H,M,S : Word);
  388. Remarks         Displays the time in the format HH:MM:SS in the current
  389.         colour and character size. The current justification is also 
  390.         used. X,Y is the position of the clock.
  391. Restrictions    Must be in graphics mode and be using the Graph unit.
  392. Example 
  393.         Uses GClocks;
  394.             Var H,M,S,SS,OH,OM,OS : word;
  395.         Begin
  396.             { set up graphics mode here }
  397.             Repeat
  398.                 GetTime(H,M,S,SS);
  399.                 If S<>OS then
  400.                 Begin
  401.                     SetColor(Black);
  402.                     DClock(50,50,OH,OM,OS);
  403.                     SetColor(White);
  404.                     DClock(50,50,H,M,S);
  405.                     OS:=S;
  406.                     OM:=M;
  407.                     OH:=H;
  408.                 End; {if}
  409.             Until False;
  410.         End;
  411.  
  412. DCos function - Maths
  413. Function        Returns the cosine of the argument.
  414. Declaration     DCos ( X : Real );
  415. Result Type     Real
  416. Remarks         X is a real type expression. The result is the cosine
  417.         of X. Where X is assumed to be an angle in degrees.
  418. Example 
  419.         Uses Maths;
  420.         Begin
  421.             Writeln (DCos(90)); { 0 }
  422.         End;
  423.  
  424. DSin function - Maths
  425. Function        Returns the sine of the argument.
  426. Declaration     DSin ( X : Real );
  427. Result Type     Real
  428. Remarks         X is a real type expression. The result is the sine of
  429.         X. Where X is assumed to be an angle in degrees.
  430. Example 
  431.         Uses Maths;
  432.         Begin
  433.             Writeln (DSin(90)); { 1 }
  434.         End.
  435.  
  436. DTan function - Maths
  437. Function        Returns the tangent of the argument.
  438. Declaration     DTan ( X : Real );
  439. Result Type     Real
  440. Remarks         X is a real type expression. The result is the tangent
  441.         of X. Where X is assumed to be an angle in degrees.
  442. Example 
  443.         Uses Maths;
  444.         Begin
  445.             Writeln (DTan(180)); { 0 }
  446.         End.
  447.  
  448. Empty_Elements constant - Matrices
  449. Function        An empty matrix (see Matrix type)
  450. Declaration     const empty_elements : elements = (
  451.                         (0,0,0,0,0),
  452.                         (0,0,0,0,0),
  453.                         (0,0,0,0,0),
  454.                         (0,0,0,0,0),
  455.                         (0,0,0,0,0));
  456.  
  457. Empty_Matrix procedure - Matrices
  458. Function        Empties a matrix.
  459. Declaration     Empty_Matrix (var M : Matrix);
  460. Remarks         Returns M empty.
  461.  
  462. ESetRes procedure - Grafix
  463. Function        Puts a value into the VGA ESetRes register.
  464. Declaration     ESetRes (P : Byte);
  465. Remarks         The byte P will be placed into the register.
  466.  
  467. Factorial function - Maths
  468. Function        Returns the factorial of the argument.
  469. Declaration     Factorial ( X : Integer );
  470. Result Type     Real
  471. Remarks         X is an integer type expression. The result is the
  472.         factorial of X otherwise known as X!. 
  473. Example 
  474.         Uses Maths;
  475.         Begin
  476.             Writeln (Factorial(5)); { 125 }
  477.         End.
  478.  
  479.  
  480.  
  481. FastPlot procedure - Grafix
  482. Function        Plots a pixel onto an EGA/VGA screen.
  483. Declaration     FastPlot (X,Y : Word; C : Byte);
  484. Remarks         Plots a pixel at X,Y in colour C. This routine contains
  485.         no error checking to see whether the screen is in graphics 
  486.         mode. It is at least three times faster than the Graph 
  487.         PutPixel procedure.
  488. Restrictions    Must be in graphics mode.
  489.  
  490. FlyBack function - VGA
  491. Function        Waits for a screen flyback.
  492. Declaration     FlyBack;
  493. Remarks         This waits for a screen flyback to occur.
  494.  
  495. GetButton  function - Mouse
  496. Function        Returns status of the mouse buttons.
  497. Declaration     GetButton;
  498. Result Type     Byte
  499. Remarks         The returned byte contains the status of the mouse
  500.         buttons. If a button is down then it's corresponding bit is 
  501.         set. Bit 0 represents the left button, bit 2 the middle 
  502.         button and bit 1 the right button. 
  503. Restrictions    If the code between different calls to GetButton is
  504.         small then the results may conflict. If this
  505.         does occur then use a DELAY statement from the CRT unit to 
  506.         pad out your code. 250mS should be ample.
  507. Example 
  508.         Uses Mouse;
  509.         Begin
  510.             if not MReset then Halt(0);
  511.             Writeln ('Press left mouse button');
  512.             repeat until GetButton=1;
  513.             Writeln ('Press right mouse button');
  514.             repeat until GetButton=2;
  515.         End.
  516.  
  517. GetButtonPress procedure - Mouse
  518. Function        Retrieve information about a button press.
  519. Declaration     GetButtonPress ( Button : Byte; var BPN,X,Y : Word;);
  520. Remarks         Button is equal to 0 for the left button, 2 for the
  521.         middle button and 1 for the right button. BPN
  522.         is the number of times that Button has been pressed since the
  523.         last time that this procedure was called for that Button. 
  524.         X and Y contain the coordinates of the last Button press.
  525. Example 
  526.         Uses Mouse;
  527.             Var BPN,X,Y : Word;
  528.         Begin
  529.             if not MReset then Halt(0);
  530.             Writeln ('Press left button a few times and then 
  531.         press the right button.');
  532.             GetButtonPress (0,BPN,X,Y);
  533.             repeat until GetButton=2;
  534.             GetButtonPress (0,BPN,X,Y);
  535.             Writeln ('You pressed the left button ',BPN,' 
  536.         times.');
  537.         End.
  538.  
  539. GetButtonRelease procedure - Mouse
  540. Function        Retrieve information about a button release.
  541. Declaration     GetButtonRelease ( Button : Byte; var BRN,X,Y : Word; );
  542. Remarks         Button is equal to 0 for the left button, 2 for the
  543.         middle button and 1 for the right button. BRN is the number 
  544.         of times that Button has been released since the last time 
  545.         that this procedure was called for that Button. X and Y 
  546.         contain the co-ordinates of the last Button release.
  547. Example See GetButtonPress
  548.  
  549. GetMotion procedure - Mouse
  550. Function        Reads and returns the value of the mouse motion counters.
  551. Declaration     GetMotion ( var X,Y : Integer );
  552. Remarks         The values X and Y are the net mouse displacement since
  553.         the last call to this procedure. They are measured in mickeys, 
  554.         where 1 mickey equals 1/200". A positive number indicates
  555.         movement to the right or downwards.
  556. Example 
  557.         Uses Mouse;
  558.             Var X,Y : Integer;
  559.         Begin
  560.             if not MReset then Halt(0);
  561.             repeat
  562.                 GetMotion (X,Y);
  563.                 if X<0 then Writeln ('Right');
  564.                 if X>0 then Writeln ('Left');
  565.                 if Y<0 then Writeln ('Up');
  566.                 if Y>0 then Writeln ('Down');
  567.             until GetButton>0;
  568.         End.
  569.  
  570. GetPos procedure - Mouse
  571. Function        Get current posistion of mouse.
  572. Declaration     GetPos ( var X,Y : Word );
  573. Remarks         GetPos returns in X and Y the current coordinate of the
  574.         mouse pointer, it is always measured in pixels.
  575. Example 
  576.         Uses Crt,Mouse;
  577.             Var X,Y : Word;
  578.         Begin
  579.             if not MReset then Halt(0);
  580.             repeat
  581.                 ClrScr;
  582.                 GetPos (X,Y);
  583.                 Writeln ('X: ',X,'Y:',Y,'');
  584.             until GetButton>0;
  585.         End.
  586.  
  587. Hex function - Basen
  588. Function        Converts a decimal value into a hexidecimal string.
  589. Declaration     Hex ( Length : Byte; Dec_Val : Word; LZero : Boolean );
  590. Result Type     String
  591. Remarks         Converts Dec_Val into a string of Length representing
  592.         the Hexidecimal equivalent. If LZero is True then leading 
  593.         zeros are suppressed.
  594. Restrictions    Length must be between 1 and 4.
  595. Example 
  596.         Uses Basen;
  597.         Begin
  598.             Writeln (Hex(4,1234,True));{ 4D2 }
  599.             Writeln (Hex(4,1234,False)); { 04D2 }
  600.         End.
  601.  
  602. HexArray constant - Basen
  603. Function        Constant array containing the Hexidecimal numbers.
  604. Declaration     HexArray : Array [0..15] of Char = (
  605. '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
  606.  
  607. Hidden Area type - Screen
  608. Function        Used with Restore_Box and Clear_Box.
  609. Declaration     Type Hidden_Area = array [1..280] of Word;
  610.  
  611. HLine procedure - VGA
  612. Function        Draws a horizontal line in mode 13h.
  613. Declaration     HLine ( L,X,Y : Word; Col : Byte );
  614. Remarks         Draws a horizontal line of length L starting at X,Y and
  615.         in colour  Col in mode 13h (320x200x256 VGA graphics mode).
  616.  
  617. Input_Matrix procedure - Matrices
  618. Function        Used to input a matrix.
  619. Declaration     Input_Matrix ( X,Y : Byte; M : Matrix );
  620. Remarks         Allows the user to enter the elements of a matrix. The
  621.         resultant matrix is stored in M and is input with the top 
  622.         left corner given by X,Y.
  623. Example 
  624.         Uses CRT, Matrices;
  625.             Var M, NM : Matrix;
  626.         Begin
  627.             ClrScr;
  628.             Create_Matrix ( 3,3,M ); { create a 3x3 matrix }
  629.             Input_Matrix (1,1,M); { get some elements }
  630.             Add_Matrix ( M,M,NM ); { add matrix to itself }
  631.             Display_Matrix (10,10,M); { display it }
  632.         End.
  633.  
  634. IsIt function - Mouse
  635. Function        Determines whether or not the pointer is in a given area.
  636. Declaration     IsIt ( X1,Y1,X2,Y2 : Word );
  637. Result Type     Boolean
  638. Remarks         X1 and Y1 are the coordinates of the top left hand
  639.         corner of a rectangular region of the screen. X2 and Y2 are 
  640.         the coords of the bottom right hand corner. IsIt returns true 
  641.         if the mouse pointer lies in this region.
  642. Example 
  643.         Uses Mouse;
  644.         Begin
  645.             if not MReset then Halt(0);
  646.             SetPointer (True);
  647.             repeat
  648.                 if IsIt(0,0,640,8) then
  649.                     Writeln ('Mouse Pointer on line 1');
  650.                 end; { if }
  651.             until GetButton>0;
  652.         End.
  653.  
  654. IsVGA function - VGA
  655. Function        Checks to see if the display adaptor is VGA.
  656. Declaration     IsVGA;
  657. Result Type     Boolean
  658. Remarks         This returns true if the display adaptor is a VGA
  659.         compatible one.
  660.  
  661. KeyPress function - Screen
  662. Function        Checks to see if a keypress has occured.
  663. Declaration     KeyPress;
  664. Result Type     Boolean
  665. Remarks         This  returns true if a key has been pressed. Unlike
  666.         the CRT KeyPressed extended keys are also detected.
  667.  
  668. Matrix type - Matrices
  669. Function        Defines a type for use in Matrices
  670. Declaration     Type    Elements = array [1..5,1..5] of integer;
  671.         Type    Matrix = record
  672.                     Cols : Byte;
  673.                     Rows : Byte;
  674.                     Element   : Elements;
  675.                  End;
  676.  
  677. MDA_Clear - Mda
  678. Function        Clears the MDA Screen
  679. Declaration     MDA_Clear;
  680. Remarks         A sort of ClrScr for the MDA.
  681.  
  682. MDA constants - Mda
  683. Function        Defines constants for the various screen attributes. B
  684.         stands for Bold.
  685. Declaration     Const   Invisible = $0000;
  686.             Underline = $0100;
  687.             Normal = $0700;
  688.             BUnderline = $0900;
  689.             Bold = $0F00;
  690.             Reverse = $7000;
  691.             Blink = $8700;
  692.             BBlink = $8F00;
  693.             BReverse = $F000;
  694.             
  695. MDA_Style variable - Mda
  696. Function        Dictates the style used with MDA_Write and MDA_Wrint.
  697.         It can be assigned any of the values given in MDA constants.
  698. Declaration     var MDA_Style : word;
  699.  
  700. MDA_Wrint procedure - Mda
  701. Function        Writes an integer on an MDA Screen
  702. Declaration     MDA_Wrint ( X,Y,L : Byte; I : Integer);
  703. Remarks         Writes the integer, I, (including Bytes and Words) on
  704.         the MDA screen at the position X,Y with length L. The style 
  705.         is given by the MDA_Style variable.
  706. Example         See MDA_Write.
  707.  
  708. MDA_Write procedure - Mda
  709. Function        Writes a string on an MDA Screen
  710. Declaration     MDA_Write ( X,Y : Byte; S : String);
  711. Remarks         Writes the string, S, on the MDA screen at the position
  712.         X,Y. The style is given by the MDA_Style variable.
  713. Example 
  714.         Uses Mda;
  715.         Begin
  716.             MDA_Clear;
  717.             MDA_Style:=Reverse; { use reverse video }
  718.             MDA_Wrint (10,10,5,1000); { write 1000 on the MDA }
  719.             MDA_Style=BUnderline; { use bold and underline }
  720.             MDA_Write (20,20,'Bold and Underlined!');
  721.             ReadLn;
  722.         End.
  723.  
  724. MReset function - Mouse
  725. Function        Resets mouse.
  726. Declaration     MReset;
  727. Result Type     Boolean
  728. Remarks         This  should always be called at the start of a program
  729.         that uses Mouse. It will return True if a valid mouse driver 
  730.         is found. This  also does the following:
  731.             Y The pointer is centralised and hidden.
  732.             Y The Display page is set to 0 and the default shapes 
  733.               and styles for the pointer are employed.
  734.             Y Limits are set to be the entire screen.
  735. Example 
  736.         Uses Mouse;
  737.         Begin
  738.             if not MReset then
  739.                 Writeln ('No Mouse Driver!');
  740.             else
  741.                 Writeln ('Mouse Driver Found!);
  742.         End.
  743.  
  744. Multiply_Matrix procedure - Matrices
  745. Function        Multiplies two matrices.
  746. Declaration     Multiply_Matrix ( M1, M2 : Matrix; var M : Matrix );
  747. Remarks         Returns in matrix M the result of M1*M2.
  748.  
  749. Oct function - Basen
  750. Function        Converts a decimal value into an octal string.
  751. Declaration     Oct ( Length : Byte; Dec_Val : Word; LZero : Boolean );
  752. Result Type     String
  753. Remarks         Converts Dec_Val into a string of Length representing
  754.         the Octal Equivalent. If LZero is True then leading zeros are 
  755.         suppressed.
  756. Restrictions    Length must be between 1 and 6.
  757. Example 
  758.         Uses Basen;
  759.         Begin
  760.             Writeln (Oct(4,20,True)); { 24 }
  761.             Writeln (Oct(4,20,False)); { 0024 }
  762.         End.
  763.  
  764. Offset procedure - Grafix
  765. Function        Puts a value into the VGA Offset register.
  766. Declaration     Offset (P : Byte);
  767. Remarks         The byte P will be placed into the register.
  768.  
  769. OpenVGA procedure - VGA
  770. Function        Switches to mode 13h
  771. Declaration     OpenVGA;
  772. Remarks         Makes mode 13h the current mode (320x200x256 VGA
  773.         graphics mode). Check that the card is a VGA with IsVGA 
  774.         before using this procedure.
  775.  
  776. PelPan procedure - Grafix
  777. Function        Puts a value into the VGA PelPan register.
  778. Declaration     PelPan (P : Byte);
  779. Remarks         The byte P will be placed into the register.
  780.  
  781. Power function - Maths
  782. Function        Returns arg1 to the power of arg2.
  783. Declaration     Power (Arg1 : Integer; Arg2 : Real);
  784. Result Type     Real
  785. Remarks         Returns Arg1 to the power of Arg2 i.e. Arg1Arg2.
  786. Example 
  787.         Uses Maths;
  788.         Begin
  789.             Writeln ('5^3=',Power(5,3)); { 125 }
  790.         End;
  791.  
  792. PreRow procedure - Grafix
  793. Function        Puts a value into the VGA PreRow register.
  794. Declaration     PreRow (P : Byte);
  795. Remarks         The byte P will be placed into the register.
  796.  
  797. PutPixel procedure - VGA
  798. Function        Colours a pixel in mode 13h.
  799. Declaration     PutPixel ( X,Y : Word; Col : Byte );
  800. Remarks         Sets the pixel at X,Y to colour Col in mode 13h
  801.         (320x200x256 VGA graphics mode).
  802.  
  803. R2D function - Maths
  804. Function        Converts degrees radians to degrees.
  805. Declaration     R2D ( X : Real );
  806. Result Type     Real
  807. Remarks         X is a real type expression representing an angle in
  808.         degrees radians. The result represents the angle in degrees.
  809. Example 
  810.         Uses Maths;
  811.         Begin
  812.             Writeln (R2D(1.57));{ 90 }
  813.         End.
  814.  
  815. Replicate procedure - Screen
  816. Function        Outputs multiple copies of a character.
  817. Declaration     Replicate (N : Word; C : Char);
  818. Remarks         Writes N copies of C starting at the current cursor
  819.         location and in the current screen colours.
  820.  
  821. Restore_Box procedure - Screen
  822. Function        Replaces a hidden area.
  823. Declaration     Restore_Box ( H : Hidden_Area );
  824. Remarks         H represents a 20x10 box removed from the screen. This
  825.         procedure simply replaces it.
  826. Example 
  827.         Uses Screen;
  828.             Var H : Hidden_Area;
  829.         Begin
  830.             Clear_Box (10,H);
  831.             Repeat Until Keypress;
  832.             Restore_Box (H);
  833.         End.
  834.  
  835. RTan function - Maths
  836. Function        Returns the tangent of the argument.
  837. Declaration     RTan ( X : Real );
  838. Result Type     Real
  839. Remarks         X is a real type expression. The result is the tangent
  840.         of X. Where X is assumed to be an angle in degrees radians.
  841. Example 
  842.         Uses Maths;
  843.         Begin
  844.             Writeln (RTan(PI)); { 0 }
  845.         End.
  846.  
  847. ScreenOff procedure - Grafix
  848. Function        Turns an EGA/VGA screen off.
  849. Declaration     ScreenOff ;
  850. Remarks         Turns the screen off. Does not have to be in graphics mode.
  851.  
  852. ScreenOn procedure - Grafix
  853. Function        Fucntion Turns an EGA/VGA screen on.
  854. Declaration     ScreenOn;
  855. Remarks         Turns the screen on. Does not have to be in graphics mode.
  856.  
  857. SearchString function - Screen
  858. Function        Checks to see if a substring exists in a string.
  859. Declaration     SearchString ( S,SS : String );
  860. Result Type     Boolean
  861. Remarks         Returns True if SS exists in S. Lower and Upper case
  862.         are different. Use UpString to convert both strings to 
  863.         uppercase if no distinction between case is required. 
  864.         e.g. SearchString (UpString(s),UpString (ss));
  865.  
  866. SetActivePage - Grafix
  867. Function        Alters the active page.
  868. Declaration     SetActivePage ( P : Byte );
  869. Remarks         Sets the active page to be P. No checking is done to
  870.         see if this is a valid page or not.
  871.  
  872. SetGPointer procedure - Mouse
  873. Function        Defines the shape, colour and hotspot of the pointer
  874.         in graphics modes.
  875. Declaration     SetGPointer ( X,Y,OS,SE : Word );
  876. Remarks         X and Y are the coordinates of the hotspot relative to
  877.         the top left corner of the pointer (0,0).
  878.         SE:OS points to a pointer image buffer which is 64 bytes long.
  879.         The first 32 bytes contain an ANDed bitmask whilst the second 
  880.         32 bytes contain a XORed bitmask. The pointer is 16x16
  881.         pixels. The layout of the buffer is a 64 byte array. When
  882.         arranged in a 32 row by 2 coloumn layout the first coloumn 
  883.         represents the right half of the pointer and the second 
  884.         column represents the left half (I know it's backwards but I 
  885.         never wrote it!). The AND and XOR bits do the following.
  886.  
  887.         AND bit      XOR bit   resultant pixel colour 
  888.         0            0         background 
  889.         0            1         XOR background 
  890.         1            0         foreground (see thro') 
  891.         1            1         XOR foreground 
  892. Example 
  893.         { A 16x16 hollow box would be defined as a 
  894.         mixture of the following:- 
  895.         $80 in binary  $01 in binary
  896.         10000000       00000001 
  897.         11111111       11111111 
  898.         $FF in binary  $FF in binary
  899.         The hotspot is in the top left corner.}
  900.         Const
  901.             Box : Array [1..63] of Byte = (
  902.                         $FF,$FF,
  903.                         $01,$80,
  904.                         $01,$80,
  905.                         $01,$80,
  906.                         $01,$80,
  907.                         $01,$80,
  908.                         $01,$80,
  909.                         $01,$80,
  910.                         $01,$80,
  911.                         $01,$80,
  912.                         $01,$80,
  913.                         $01,$80,
  914.                         $01,$80,
  915.                         $01,$80,
  916.                         $01,$80,
  917.                         $FF,$FF,
  918.                         $FF,$FF,
  919.                         $01,$80,
  920.                         $01,$80,
  921.                         $01,$80,
  922.                         $01,$80,
  923.                         $01,$80,
  924.                         $01,$80,
  925.                         $01,$80,
  926.                         $01,$80,
  927.                         $01,$80,
  928.                         $01,$80,
  929.                         $01,$80,
  930.                         $01,$80,
  931.                         $01,$80,
  932.                         $01,$80,
  933.                         $FF,$FF);
  934.         Begin
  935.             { set up graphics display here }
  936.             If not MReset then Halt (0);
  937.             SetPointer (True);
  938.             SetGPointer (1,1,Ofs(Box),Seg(Box));
  939.             repeat until GetButton>0;
  940.         End.
  941.  
  942. SetLimits procedure - Mouse
  943. Function        Limits the mouse pointer display area.
  944. Declaration     SetLimits ( X1,Y1,X2,Y2 : Word );
  945. Remarks         Sets the limits for the mouse pointer by assigning an
  946.         area where the pointer is restricted to. The mouse pointer 
  947.         will be moved (if necessary) to fit in the area. The area is
  948.         a rectangle with X1,Y1 being the coordinate of the top left 
  949.         corner and X2,Y2 being the coordinate of the bottom right 
  950.         corner.
  951. Example 
  952.         Uses Mouse;
  953.         Begin
  954.             if not MReset then Halt (0);
  955.             SetPointer (True);
  956.             Writeln ('Mouse restricted to top half of the
  957.         screen.');
  958.             SetLimits (0,100,632,100);
  959.             repeat until GetButton>0;
  960.         End.
  961.  
  962. SetMode procedure - Grafix
  963. Function        Puts the screen into a different mode.
  964. Declaration     SetMode ( P : Byte  );
  965. Remarks         Sets the screen mode to that of P. Note that this
  966.         procedure does not check to see if P is a valid mode.
  967.  
  968. SetNoLimits procedure - Mouse
  969. Function        Defines an exclusion area for the pointer.
  970. Declaration     SetNoLimits ( X1,Y1,X2,Y2 : Word );
  971. Remarks         X1,Y1 are the coordinates of the top left corner of a
  972.         rectangle. X2,Y2 are the coordinates of the bottom right hand 
  973.         corner. The mouse pointer will not be displayed whilst in 
  974.         this area. The exclusion area is replaced with another call 
  975.         to SetNoLimits or cancelled with a call to SetPointer (True) 
  976.         or MReset.
  977. Example 
  978.         Uses Mouse;
  979.         Begin
  980.             if not MReset then Halt(0);
  981.             SetPointer (True);
  982.             Writeln ('Mouse pointer will not be shown in center of 
  983.         screen');
  984.             SetNoLimits (220,50,420,150);
  985.             repeat until GetButton>0;
  986.             SetPointer (True);
  987.         End.
  988.  
  989. SetPointer procedure - Mouse
  990. Function        Hides and shows mouse pointer.
  991. Declaration     SetPointer ( Point : Boolean );
  992. Remarks         If point is True then the mouse pointer is displayed
  993.         otherwise if point is False then the pointer is hidden.
  994. Example 
  995.         Uses Crt,Mouse;
  996.         Begin
  997.             if not MReset then Halt(0);
  998.             Writeln ('Press a button to show pointer');
  999.             repeat until GetButton>0;
  1000.             Delay (250);{ see GetButton for this }
  1001.             SetPointer (True);
  1002.             Writeln ('Press a button to exit');
  1003.             repeat until GetButton>0;
  1004.         End.
  1005.  
  1006. SetPointerPage procedure - Mouse
  1007. Function        Selects the display page for the mouse pointer.
  1008. Declaration     SetPointerPage ( Page : Byte );
  1009. Remarks         Page is the page number where the pointer will be
  1010.         displayed. Valid page numbers depend on the current display 
  1011.         mode.
  1012.  
  1013. SetPos procedure - Mouse
  1014. Function        Set posistion of mouse pointer.
  1015. Declaration     SetPos ( X,Y : Word );
  1016. Remarks         Moves the mouse pointer to coordinate X,Y. The
  1017.         posistion is adjusted ( if necessary ) to lie within the 
  1018.         boundry defined by SetLimits.
  1019. Example 
  1020.         Uses Mouse;
  1021.             Var X,Y : Word;
  1022.         Begin
  1023.             if not MReset then Halt(0);
  1024.             SetPointer (True);
  1025.             Write ('Enter X coord: ');
  1026.             Readln (X);
  1027.             Writeln;
  1028.             Write ('Enter Y coord: ');
  1029.             Readln (Y);
  1030.             SetPos (X,Y);
  1031.         End.
  1032.  
  1033. SetRes procedure - Grafix
  1034. Function        Puts a value into the VGA SetRes register.
  1035. Declaration     SetRes (P : Byte);
  1036. Remarks         The byte P will be placed into the register.
  1037.  
  1038. SetTPointer procedure - Mouse
  1039. Function        Defines the shape and attributes of the mouse pointer
  1040.         in text modes.
  1041. Declaration     SetTPointer ( ANDM, XORM : Word; SH : Boolean );
  1042. Remarks         If SH is True then the hardware cursor is used.This
  1043.         cursor is defined by CursorOn or is the default cursor. 
  1044.         If SH is False then ANDM is the AND mask value and XORM is 
  1045.         the XOR mask value. The following table shows how to define
  1046.         these masks.
  1047.             Bits    Significance 
  1048.             0-7     Character Code 
  1049.             8-10    Foreground Colour 
  1050.             11      Intensity (or upper block of colours) 
  1051.             12-14   BackGround Colour 
  1052.             15      Blink (or upper block of colours) 
  1053.             
  1054.         The default values are ANDM = $77FF and XORM = $7700.
  1055.         All the mouse routines work with pixels even in text mode
  1056.         where we would use character spaces. Conversion is easy as 
  1057.         in 80x25 text mode the screen is 640x200 pixels. This
  1058.         obviously means that each character is 8x8 pixels. So to get
  1059.         from characters to pixels multiply by 8 and to get from 
  1060.         pixels to characters divide by 8. That's not quite right 
  1061.         because of the posistion of the hotspots in text mode. The 
  1062.         character posistions start at 1,1 whilst pixels start at 0,0. 
  1063.         So you have to take one away from your character locations 
  1064.         before you multiply. Likewise when converting from pixels to 
  1065.         characters you have to add one to each of the locations after 
  1066.         division. As a simple example say we wanted to restrict the 
  1067.         mouse to a box on the screen where the top left coord is 5,10
  1068.         and the bottom right coord is 30,20. We simply take one from 
  1069.         each of these and multiply by 8.
  1070.  
  1071.             4* 8 = 32
  1072.             9* 8 = 72
  1073.             29 * 8 = 232
  1074.             19 * 8 = 152
  1075.             
  1076.         So our call to SetLimits will look like this:
  1077.  
  1078.             SetLimit (32,72,232,152);
  1079.             
  1080.         In 43x80 or 50x80 mode each character is only 8x8 but the
  1081.         screen dimensions are 640x344 and 640x400 respectivley.
  1082. Example 
  1083.         Uses Mouse;
  1084.         Begin
  1085.             if not MReset then Halt(0);
  1086.             Writeln ('New Style Pointer!');
  1087.             SetTPointer ($7777,$FFFF,False);
  1088.             repeat until GetButton>0;
  1089.         End.
  1090.  
  1091. Sinh function - Maths
  1092. Function        Returns the Hyp sine of the argument.
  1093. Declaration     Sinh (X : Real);
  1094. Result Type     Real
  1095. Remarks         X is a real type expression. The result is Hyp sine of X.
  1096. Example 
  1097.         Uses Maths;
  1098.         Begin
  1099.             Writeln (Sinh(2));{ 3.6268 }
  1100.             Writeln (Sinh(-4)); { -27.29 }
  1101.         End.
  1102.         
  1103. StartAddr procedure - Grafix
  1104. Function        Puts a value into the VGA Start Address register.
  1105. Declaration     StartAddr (P : Byte);
  1106. Remarks         The byte P will be placed into the register.
  1107.  
  1108. Subtract_Matrix procedure - Matrices
  1109. Function        Subtracts two matrices.
  1110. Declaration     Subtract_Matrix ( M1,M2 : Matrix; var M : Matrix );
  1111. Remarks         Returns in matrix M the result of M1 - M2.
  1112.  
  1113. Tanh function - Maths
  1114. Function        Returns the Hyp Tangent of the argument.
  1115. Declaration     Tanh (X : Real);
  1116. Result Type     Real
  1117. Remarks         X is a real type expression. The result is Hyp tangent
  1118.         of X.
  1119. Example 
  1120.         Uses Maths;
  1121.         Begin
  1122.             Writeln (Tanh(2));{ 0.964}
  1123.             Writeln (Tanh(-4)); { -0.999 }
  1124.         End.
  1125.  
  1126. UpString function - Screen
  1127. Function        Converts a string to uppercase.
  1128. Declaration     UpString ( S : String );
  1129. Result Type     String
  1130. Remarks         Returns S in uppercase. Non alphabetic characters are
  1131.         left alone.
  1132. Example 
  1133.         Uses Screen;
  1134.         Begin
  1135.             Writeln (UpString ('rafe's tp collection'));
  1136.         End.
  1137.         
  1138. VLine procedure - VGA
  1139. Function        Draws a vertical line in mode 13h.
  1140. Declaration     VLine ( L,X,Y : Word; Col : Byte );
  1141. Remarks         Draws a vertical line of length L starting at X,Y and
  1142.         in colour  Col in mode 13h (320x200x256 VGA graphics mode).
  1143.  
  1144. VGAOff procedure - VGA
  1145. Function        Turns off the VGA screen.
  1146. Declaration     VGAOff;
  1147. Remarks         Turns off the VGA screen.
  1148.  
  1149. VGAOn procedure - VGA
  1150. Function        Turns on the VGA screen.
  1151. Declaration     VGAOn;
  1152. Remarks         Turns on a VGA screen having been switched off with VGAOff.
  1153.  
  1154. Wallpaper procedure - Screen
  1155. Function        Wallpapers the screen.
  1156. Declaration     Wallpaper (C : Char);
  1157. Remarks         Fills the screen with character C in the current screen
  1158.         colours. 
  1159.  
  1160. Wrte procedure - Screen
  1161. Function        Faster version of WRITE.
  1162. Declaration     Wrte (X,Y:Byte; Var S:String; F,G:Byte);
  1163. Remarks         Writes a the string S directly into video RAM at the
  1164.         screen posistion denoted by X,Y. F is the foreground color 
  1165.         whilst B is the background color. NOTE: this procedure causes 
  1166.         snow on a CGA adaptor.
  1167.  
  1168.  
  1169.